<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    button.active{
      background: red;
    }
    .content{
      width:200px;
      height:200px;
      border: 1px solid #333;
      font-size: 30px;
      text-align:center;
      line-height: 200px;
    }
  </style>
</head>
<body>
  <div id="app">
    <button 
      v-for="(el,index) in arr" 
      :class="{active:num===index}"
      @click="tabs(index)"
      :key="el.title">{{el.title}}</button>
    <div 
      
        v-for="(el,index) in arr" 
        :key="el.content" 
        class="content"
        v-show="num===index"
      >
      {{ el.content }}
    </div>
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: "#app",
      data: {
        num: 0,
        arr:[
          {
            title:"选项1",
            content:"内容1"
          },
          {
            title:"选项2",
            content:"内容2"
          },
          {
            title:"选项3",
            content:"内容3"
          },
          {
            title:"选项4",
            content:"内容4"
          }
        ]
      },
      methods:{
        tabs(n){
          this.num = n
        }
      }
    })
  </script>
</body>
</html>
